using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class userMap : EntityTypeConfiguration<user>
    {
        public userMap()
        {
            // Primary Key
            this.HasKey(t => t.user_id);

            // Properties
            this.Property(t => t.user_id)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("users");
            this.Property(t => t.user_id).HasColumnName("user_id");
            this.Property(t => t.role_id).HasColumnName("role_id");

            // Relationships
            this.HasOptional(t => t.role)
                .WithMany(t => t.users)
                .HasForeignKey(d => d.role_id);

        }
    }
}
